#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <unordered_map>
// 等差数列划分：https://leetcode.cn/problems/arithmetic-slices/description/
using namespace std;
class Solution {
public:
    int numberOfArithmeticSlices(vector<int>& nums) {
        int n=nums.size();
        if(n<3) return 0;
        vector<int> dp(n);
        for(int i=2;i<n;i++)
            dp[i]=(nums[i]-nums[i-1]==nums[i-1]-nums[i-2])?dp[i-1]+1:0;
        int sum=0;
        for(auto x:dp) sum+=x;
        return sum;
    }
};